//同时设置相同宽高并设置成圆形
@mixin equalWH($num, $circle: true, $center: false) {
    width: $num + px;
    height: $num + px;

    @if ($circle) {
        border-radius: 50%;
    }

    @if ($center) {
        line-height: $num + px;
        text-align: center;
    }
}

//设置兼容透明度
@mixin opacity($num) {
    opacity: $num;
    filter: alpha(opacity=$num * 100);
}

//同时设置高度和行高
@mixin height($h, $oval: false) {
    height: $h + px;
    line-height: $h + px;
    @if ($oval) {
        border-radius: $h + px;
    }
}

//同时设置宽度和居中
@mixin wc($w) {
    width: $w + px;
    text-align: center;
}

//设置未知宽高元素居中
@mixin middle($x: true, $y: true) {
    position: absolute;

    @if ($x and $y) {
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
    } @else {
        @if ($x) {
            left: 50%;
            transform: translateX(-50%);
        }

        @if ($y) {
            top: 50%;
            transform: translateY(-50%);
        }
    }
}

//设置已知宽高元素居中
@mixin middleWH($width: false, $height: false, $padding: 0, $position: absolute) {
    position: $position;

    @if ($width) {
        width: $width + px;
        left: 50%;
        margin-left: -($width + $padding) / 2 + px;
    }

    @if ($height) {
        height: $height + px;
        top: 50%;
        margin-top: -($height + $padding) / 2 + px;
    }
}

//透明蒙层背景色
@mixin bgBlack($opacity) {
    background-color: rgba(0, 0, 0, $opacity);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#7F000000, endColorstr=#7F000000);
}

//单行超出宽度截取
@mixin ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

//多行超出宽度截取
@mixin moreLine($row: 2) {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: $row;
    -webkit-box-orient: vertical;
}

@mixin clear {
    &:after,
    &:before {
        content: ' ';
        display: table;
    }

    &:after {
        clear: both;
    }
}

@mixin wh($w, $h, $wc: false, $hc: false, $br: false) {
    width: $w + px;
    height: $h + px;

    @if ($wc) {
        text-align: center;
    }

    @if ($hc) {
        line-height: $h + px;
    }

    @if ($br) {
        border-radius: $h/2 + px;
    }
}

@mixin fb($fs: 14) {
    font-size: $fs + px;
    font-weight: 900;
}
